<?php
	session_start();
	require_once('common/config.php');
	require_once('../_helper/paging.php');
	require_once('../_helper/helper.php');
	require_once('../_model/product_model.php');
	require_once('../_model/brand_model.php');
	require_once('../_model/type_model.php');
	require_once('../_model/cat_model.php');
	
	$pageCMS = PAGE_CMS_SALEOFF;
	
	if(!isset($_SESSION['logon']))
	{
		header("Location: /wks/login.php?url=product");
		exit();
	}
	
	if (!isset($_GET['action']))
		$_GET['action'] = "list";
		
	$action = $_GET['action'];
	
	if($action == 'list' || $action =='search')
	{
		if(isset($_GET['page']))
			$curPage = $_GET['page'];
		else
		{
			$curPage = 1;
			unset($_SESSION['numProduct']);
		}
			
		
		/*var_dump($type_arr);die();*/
		if( !isset($_SESSION['numProduct']))
		{
			$numProduct = GetNumProductSaleoff();
			$_SESSION['numProduct'] = $numProduct;
		}
		else
			$numProduct = $_SESSION['numProduct'];
			
		$param = "action=list";	
		
		$product_arr = GetProductSaleOff($curPage, PAGING_NUM_ROW);
		
				
		//Xu ly
		require_once('template/product/product_sale_list.php');
		exit();
	}
	
?>